/**
    算法描述：
    核心问题：
    解决所需数据结构+算法：
**/
#include<iostream>
#include<cstring>
using namespace std;

string words[6] = {"in", "one", "out", "input", "puton", "output"};

bool dfs(string s) {
    bool flag = false, real_flag = false;
    if (s.empty())
        return true;
    for (int i=0; i<6; i++) {
        if (s.length() < words[i].length())
            break;
        if (s.substr(0, words[i].length()) == words[i]) {
            flag = dfs(s.substr(words[i].length(), s.length()));
            if (flag)
                real_flag = !real_flag;
        } else continue;
    }
    return real_flag;
}

int main() {
    int t;
    cin >> t;
    while (t--) {
        string str;
        cin >> str;
        if(dfs(str)) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }
    return 0;
}